package com.company.java.basic.day05;

public class Day05_ManyDimensionalArray {
    public static void main(String[] args) {
        //二维数组(静态初始化)
        /*
        //声明数组
        int[][] arr;
        arr = new int[][]{{1,2},
                          {3,4,5},
                           {6,7}};
        // 打印该数组
        for (int i=0;i<arr.length;i++){
            for (int j=0;j<arr[i].length;j++){
                System.out.print(arr[i][j]+" ");
            }
            System.out.println();
        }
        //练习
        int[][] num;
        num = new int[][]{{1,1,1,1},{2,2,2,2},{3,3,3,3}};
        for (int i=0;i<num.length;i++){
            for (int j=0;j<num[i].length;j++){
                System.out.print(num[i][j]+" ");
            }
            System.out.println();
        }

         */

        //动态初始化
        /*
        //声明
        int[][] arr ;
        //初始化(未初始化之前，堆空间不分配id给arr)
        arr = new int[3][4];
        for (int i=0;i<arr.length;i++){
            for (int j=0;j<arr[i].length;j++){
                arr[i][j] = i+1;
                System.out.print(arr[i][j]+" ");
            }
            System.out.println();
        }

        //练习
        int[][] arr2 = new int[4][];
        for (int i=1;i<= arr2.length;i++){
            arr2[i-1] = new int[i];
            for (int j=0;j<arr2[i-1].length;j++){
                arr2[i-1][j] = i;
                System.out.print(arr2[i-1][j]+" ");
            }
            System.out.println();
        }

         */



    }
}
